package com.homedo.microservice.open.service.gateway.manager.web.gateway.service;

import org.springframework.stereotype.Service;

import com.homedo.microservice.open.service.gateway.manager.web.gateway.bean.po.HealthCheckingErrorStatistics;
import com.homedo.microservice.open.service.gateway.manager.web.gateway.bean.po.enhanced.HealthCheckingErrorStatisticsEnhanced;
import com.homedo.microservice.open.service.gateway.manager.web.gateway.persistence.dao.HealthCheckingErrorStatisticsDao;
import com.homedo.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import com.homedo.common.bean.vo.context.UserContext;
import com.homedo.common.dao.bean.po.base.BasePo;
import com.google.common.collect.Lists;
import com.homedo.common.util.Detect;
import java.util.List;

/**
 *
 * @author 作者 jgshun
 * @date   创建时间 2018年10月16日 16时44分30秒
 */
@Service
public class HealthCheckingErrorStatisticsService extends BaseService<HealthCheckingErrorStatistics> {
	@Autowired
	private HealthCheckingErrorStatisticsDao healthCheckingErrorStatisticsDao;


        @Override
        public List<HealthCheckingErrorStatisticsEnhanced> getEnhanceds(List<?> ids, UserContext userContext) {
            List<HealthCheckingErrorStatistics> healthCheckingErrorStatisticss = healthCheckingErrorStatisticsDao.getListByIds(ids, HealthCheckingErrorStatistics.class);

            if (!Detect.notEmpty(healthCheckingErrorStatisticss)) {
            return null;
            }

            return this.convent2Enhanceds(healthCheckingErrorStatisticss);
        }


        @Override
        public List<HealthCheckingErrorStatisticsEnhanced> getEnhanceds4Active(List<?> ids, UserContext userContext) {
            List<HealthCheckingErrorStatistics> healthCheckingErrorStatisticss = healthCheckingErrorStatisticsDao.getListByIdsGreaterThanMark0(ids, HealthCheckingErrorStatistics.class);

                if (!Detect.notEmpty(healthCheckingErrorStatisticss)) {
                return null;
                }

            return this.convent2Enhanceds(healthCheckingErrorStatisticss);
         }


                @Override
                public List<HealthCheckingErrorStatisticsEnhanced> convent2Enhanceds(List<? extends BasePo> pos) {
                    List<HealthCheckingErrorStatistics> healthCheckingErrorStatisticss = (List<HealthCheckingErrorStatistics>) pos;
                        List<HealthCheckingErrorStatisticsEnhanced> healthCheckingErrorStatisticsEnhanceds = Lists.newArrayList();
                            healthCheckingErrorStatisticss.forEach(e -> healthCheckingErrorStatisticsEnhanceds.add(new HealthCheckingErrorStatisticsEnhanced(e)));
                            return healthCheckingErrorStatisticsEnhanceds;
                 }


}
